﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SimplexEngine
{
    public class FPSCounter
    {
        public void Update()
        {
            float delta = (float)(DateTime.Now - last_update_time).TotalSeconds;
            last_update_time = DateTime.Now;

            ++current_count;
            current_delta += delta;

            if (current_delta > 1.0f)
            {
                current_delta -= 1.0f;
                fps = current_count;
                current_count = 0;
            }
        }

        protected int current_count = 0;
        protected float current_delta = 0.0f;

        DateTime last_update_time = DateTime.Now;

        public int FPS { get { return fps; } }
        protected int fps = 0;
    }
}